from rest_framework import serializers

from sales.models import *


class ProductSalesOrderSerializer(serializers.ModelSerializer):
    order_number = serializers.ReadOnlyField()
    is_payed = serializers.ReadOnlyField()
    is_send = serializers.ReadOnlyField()
    order_state = serializers.ReadOnlyField()
    order_items = serializers.ListField(help_text='订单明细')

    class Meta:
        model = ProductSalesOrder
        exclude = ['datetime_created', 'datetime_updated']


class OrderCreateSerializer(serializers.ModelSerializer):
    order_items = serializers.ListField(help_text='订单明细')

    class Meta:
        model = ProductSalesOrder
        fields = ['address', 'customer_notes', 'order_items']


class OrderDeleteSerializer(serializers.Serializer):
    sales_id = serializers.IntegerField(help_text='订单ID')
